//
//  CommonReqManage.m
//  citzenWorkStation
//
//  Created by yang qing on 2018/2/28.
//  Copyright © 2018年 yang qing. All rights reserved.
//

#import "CommonReqManage.h"
#import "API.h"
@implementation CommonReqManage
+(instancetype)getInstance{
    static id obj = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        obj = [[self alloc]init];
    });
    return obj;
}

//登录
+ (void)LoginWidthParam:(NSDictionary *)params
                success:(SuccessBlock)successBlock
                 failed:(FailureBlock)failureBlock{
    
    //记录上次登录的时间，超过半个小时之后再次登录 代做
    
    [[self getInstance]requestWithMethod:HttpRequestMethodGet url:LOGIN param:params success:successBlock failure:failureBlock];
}

//获取验证码
+ (void)getMesgCode:(NSString *)phoneNumber
            success:(SuccessBlock)successBlock
             failed:(FailureBlock)failureBlock{
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setValue:phoneNumber forKey:@"phoneNumber"];
    [[self getInstance]requestWithMethod:HttpRequestMethodGet url:RegMobileCode param:dic success:successBlock failure:failureBlock];
}


//找回密码
+ (void)findPsw:(id)userInfo
        success:(SuccessBlock)successBlock
         failed:(FailureBlock)failureBlock{
     [[self getInstance]requestWithMethod:HttpRequestMethodGet url:FindPsw param:userInfo success:successBlock failure:failureBlock];
}
//获取上传图片路径
+ (void)getFilePath:(NSInteger)num
           fileType:(NSString *)type
             suffix:(NSString *)suffix
            success:(SuccessBlock)successBlock
             failed:(FailureBlock)failureBlock{
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setValue:@(num) forKey:@"num"];
    [dic setValue:type forKey:@"type"];
    [dic setValue:suffix forKey:@"suffix"];
    [[self getInstance]requestWithMethod:HttpRequestMethodGet url:GetFilePath param:dic success:successBlock failure:failureBlock];
}

//更新用户信息
+ (void)updateUserInfo:(id)userInfo
               success:(SuccessBlock)successBlock
                failed:(FailureBlock)failureBlock{
     [[self getInstance]requestWithMethod:HttpRequestMethodGet url:UpdateUserInfo param:userInfo success:successBlock failure:failureBlock];
}

//上传图片
+ (void)uploadHeadImg:(NSData *)imageData
             fileName:(NSString *)fileName
             fileType:(NSString *)fileType
            imagePath:(NSString *)imagePath
             progress:(ProgressBlock)progressBlock
              success:(SuccessBlock)successBlock
               failed:(FailureBlock)failureBlock{
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setValue:fileType forKey:@"type"];
    [dic setValue:imagePath forKey:@"path"];
    [[self getInstance]uploadFileMethod:UplUoadImage param:dic file:imageData fileName:fileName fileType:fileType progress:progressBlock success:successBlock failure:failureBlock];
}
//注册用户
+ (void)userRegister:(id)userInfo
             success:(SuccessBlock)successBlock
              failed:(FailureBlock)failureBlock{
    [[self getInstance]requestWithMethod:HttpRequestMethodGet url:UserRegister param:userInfo success:successBlock failure:failureBlock];
}
//实名认证
+ (void)identifyAuthentication:(id)userInfo
                       success:(SuccessBlock)successBlock
                        failed:(FailureBlock)failureBlock{
     [[self getInstance]requestWithMethod:HttpRequestMethodGet url:IdentifyAuthentication param:userInfo success:successBlock failure:failureBlock];
}


//获取网格编号
+ (void)getGridByGeo:(NSString *)geometry
             success:(SuccessBlock)successBlock
              failed:(FailureBlock)failureBlock{
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setValue:geometry forKey:@"geometry"];
    [[self getInstance]requestWithMethod:HttpRequestMethodGet url:GetGridByGeo param:dic success:successBlock failure:failureBlock];
}

@end
